home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-01-03 | 8.3 KB | 448 lines | [TEXT/sLiN] |
- ! Version 3.1.0
- !
- !$ Use this script with Class 1 fax software working in the "numeric answers"
- !$ mode (FaxSTF,Faxilitate), ARA 1.0 or 2.0,
- !$ and a BBS, E-mail or other communication server software
- !
- !$ This script allows to place fax AND ARA/data calls, and it allows to receive
- !$ fax OR ARA/data calls.
- !
- !$ A cable for hardware handshaking is required
-
- ^# Modem:
- ^2 Fax Software: = Enum("FaxSTF™"="0","Faxilitate"="1") "0"
- ^3 Error Correction: = Bool("Enabled"="AUTO","Disabled"="NORM") "NORM"
- ^4 Incoming Calls: = Enum("Fax"="0","ARA/Data"="1") "1"
- ^5 Data Port Speed: = Enum("9600","19200","38400") "19200"
- ! ------------------------------------------
- ! Resetting the modem:
- ! ------------------------------------------
- @Hangup
- SetTries 2
- Flush
- HsReset 0,0,17,19,0,0
- DtrSet
- !
- ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
- ! to enter the command mode
- !
- @Label 1
- matchclr
- matchstr 1 2 "OK\r\n"
- write "ATH0V1Q0\r"
- matchread 20
- ChrDelay 1
- Write "+++"
- ChrDelay 0
- DtrClear
- SBreak
- DtrSet
- !
- DecTries
- IfTries 0 1
- !
- ! OSErr -6019 "Modem error - the modem is not responding"
- !
- exit -6019
- @Label 2
- SetVar A "&F"
- GetOption A "DFLT" 3
- @Label 3
- write "AT^A+FCLASS=0\r"
- Jsr 100
- exit 0
-
- @Label 6
- Say "This script cannot be used with this modem"
- ifOriginate 9
- pause 1800
- @Label 9
- exit -6019
-
- ! ------------------------------------------
- ! Receiving incoming calls
- ! ------------------------------------------
- @ANSWER
- !
- ! Set the modem preferred speed first
- SerReset 19200,0,8,1
- Jsr 80
-
- @Label 10
- !
- ! Set the common options
- Jsr 70
-
- !
- ! Go to Fax receive if required
- !
- ifStr 4 40 "0"
- !
- ! ARA/Data call waiting
- !
- !
- ! Set the desired speed
- SerReset Val("^5"),0,8,1
- Jsr 80
- !
- ! Set the data options
- Jsr 75
-
- GetCommand B "Data" "M"
- GetCommand C "Data" "L"
- GetCommand D "Data" "S0"
- SetVar A "S0=7"
- ifStr D 16 "S0=0"
- ifStr D 16 ""
- SetVar A "^D"
- @Label 16
- !
- ! Set the speaker and S0
- Write "AT^A^B^C\r"
- Jsr 100
- !
- ! Everything is ready - let's sit and wait for a data call
- ! We'll wait for 2 minutes, then reinitiate the modem
- !
- Note "Waiting for an ARA/DATA call…"
- Jsr 90
- IfStr C 10 "NONE"
-
- IfOpen "Data" 21
- Jump 30
- @Label 21
- IfOpen "ARA" 22
- Jump 35
- @Label 22
- Note "Waiting for an ARA frame"
- MatchClr
- MatchStr 1 23 "^$\r"
- MatchStr 2 28 "\08\01\03\14\04\03\00\08\250\16\03"
- MatchStr 3 29 "\01\27\02\29\01\02\01\06"
- MatchRead 40
- Jump 24
- @Label 23
- QueueInput "^$\r"
- @Label 24
- Note "Non-ARA call"
- Jump 35
-
- @Label 28
- Note "ARA 1.0 call"
- Jump 30
- @Label 29
- Note "ARA 2.0 call"
- Jump 30
-
- @Label 30
- QueueInput "\r\nCARRIER ^B\r\n"
- IfStr A 31 "NONE"
- IfStr A 31 "None"
- QueueInput "\r\nREL\r\n"
- @Label 31
- IfOriginate 32
- QueueInput "\r\nRING\r\n"
- @Label 32
- Attach "ARA" (DTR)
-
- @Label 35
- GetSReg C "DATA" 4
- QueueInput "\r^CCONNECT ^B\r^C"
- ifOriginate 36
- QueueInput "\r^CRING\r^C"
- @Label 36
- HsReset 0,1,17,19,0,1
- Attach "Data" (DTR,Escape,Break)
-
- !
- ! Receiving Fax calls
- !
- @Label 40
- Write "AT+FCLASS=1\r"
- Jsr 100
- !
- ! Get the Speaker and the Ring Num options
- GetCommand B "Fax" "M"
- GetCommand C "Fax" "L"
- GetCommand D "Fax" "S0"
- SetVar A "S0=7"
- ifStr D 41 "S0=0"
- ifStr D 41 ""
- SetVar A "^D"
- @Label 41
- !
- ! Set the speaker and S0, switch to the numeric mode.
- Write "AT^A^B^CV0\r"
- Jsr 110
- !
- ! Everything is ready - let's sit and wait for a fax call
- ! We'll wait for 2 minutes, then reinitiate the modem
- Note "Waiting for a fax call…"
- Jsr 85
- IfStr C 49 "NONE"
- !
- ! Fax connection has been established (we read "CONNECT")
- ! Put the CONNECT ("1\r") back to the buffer,
- ! if it was an incoming call, put the "RING" before it
- @Label 45
- QueueInput "1\r"
- ifOriginate 47
- @Label 46
- QueueInput "2\r2\r"
- @Label 47
- Attach "Fax" (DTR,Reset(2400),IdleLimit=30)
-
- @Label 49
- Write "ATV1\r"
- Jsr 100
- Jump 40
- ! ------------------------------------------
- ! Originating a call through the "ARA" subport
- ! ------------------------------------------
- @ORIGINATE "ARA"
- SerReset Val("^5"),0,8,1
- Jsr 80
- !
- ! Set the common options
- Jsr 70
- !
- ! Set the communication options:
- Jsr 75
- !
- ! Emit the ARA script commands ("Xnn")
- Jsr 60
- !
- ! dial the number
- Write "ATD^1\r"
- !
- ! Wait for a modem response
- Jsr 90
- IfStr C 30 "DATA"
- Write "\r"
- Exit -6019
-
- ! ------------------------------------------
- ! Originating a call through the "DATA" subport
- ! ------------------------------------------
- @ORIGINATE "Data" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
- SerReset 19200,0,8,1
- Jsr 80
- !
- ! Set the common options
- Jsr 70
- !
- ! Set the communication options:
- Jsr 75
- !
- ! dial the number
- Write "ATD^1\r"
- HsReset *
- !
- ! Wait for a modem response
- Jsr 90
- IfStr C 35 "DATA"
- Write "\r"
- Exit -6019
-
- ! ------------------------------------------
- ! Originating a call through the "Fax" subPort
- ! ------------------------------------------
- @ORIGINATE "Fax" ("\r\nLineShare Line is Busy\r\nBUSY\r\n")
- !
- ! Set the "Fax" speed
- !
- SerReset 19200,0,8,1
- Jsr 80
- !
- ! Set the common options
- !
- Jsr 70
- GetOption A "SWHS" 6
- !
- ! Set the Fax mode (Xon/Xoff)
- Write "AT^A+FCLASS=1\r"
- Jsr 100
- !
- ! Now emit all commands that the application has sent to that port,
- ! except "+FCLASS", etc
- !
- EmitClear "+FCLASS","V","E"
- Jsr 60
- !
- ! Prepare to receive all error result codes, dial the number
- !
- Write "ATV0D^1\r"
- HsReset *
- Jsr 85
- IfStr C 45 "FAX"
- Write "\r"
- Exit -6019
- !
- !
- ! This section emits all modem commands sent from the client application
- ! For each set of commands the "OK" answer is awaited
- !
- @Label 60
- EmitStart
- @Label 61
- EmitCommand 62
- Jsr 100
- Jump 61
- @Label 62
- return
- !
- ! This section initiates the modem before ANSWER and ORIGINATEs:
- ! extended responses + connect at the highest rate + speaker control +
- ! reset on Dtr drop + DCD valid
- ! Verbal responses mode, no echo
- !
- @Label 70
- Write "AT&D2&C1V1E0\r"
- Jsr 100
- return
-
- ! Set the communication options:
- ! • Normal/AUTO Connection
- ! • HW flow control (for ARA, Fax should not use a handshake on receiving)
- ! • CONNECT <DCE speed> or CARRIER/CONNECT
- @Label 75
- GetOption A "HWHS" 6
- GetOption B "^3" 6
- GetOption C "LNRS" 6
- Write "AT^A^B^C\r"
- Jump 100
-
- !
- ! This section syncronize the modem after the serial port speed switching
- !
- @Label 80
- ChrDelay 1
- Write "AT\r"
- ChrDelay 0
- Jsr 100
- return
- !
- ! Error Codes
- @Label 81
- exit -6020
- @Label 82
- exit -6022
- @Label 83
- exit -6021
- @Label 84
- exit -6023
-
- !
- ! Connecting in the numeric mode (fax)
- ! On exit:
- ! ^C contains "NONE" if no connection has been established
- @Label 85
- MatchClr
- MatchStr 1 88 "1\r"
- MatchStr 2 87 "2\r"
- MatchStr 5 81 "6\r"
- MatchStr 6 82 "7\r"
- MatchStr 7 83 "3\r"
- MatchStr 8 84 "8\r"
- @Label 86
- Matchread 1200
- SetVar C "NONE"
- return
-
- @Label 87
- Note "Ring…"
- Jump 86
- @Label 88
- SetVar C "FAX"
- return
-
- !
- ! This subroutine waits for the modem response (data mode)
- ! On exit:
- ! ^A contains the protocol used
- ! ^B contains the carrier speed
- ! ^C contains "NONE" if no connection has been established
- ! If modem reports an error, the scripts exits with an error code
- !
- @Label 90
- SetVar A "NONE"
- SetVar B ""
- MatchClr
- Matchstr 1 92 "CARRIER ^$\r\n"
- Matchstr 2 93 "PROTOCOL: ^$\r\n"
-
- Matchstr 4 95 "CONNECT ^$/"
- Matchstr 5 97 "CONNECT ^$\r\n"
- Matchstr 6 94 "RING\r\n"
- Matchstr 10 82 "BUSY\r\n"
- MatchStr 11 83 "NO CARRIER\r\n"
- MatchStr 12 84 "NO ANSWER\r\n"
- @Label 91
- Matchread 1200
- SetVar C "NONE"
- return
-
- @Label 92
- SetVar B "^$"
- Jump 91
- @Label 93
- SetVar A "^$"
- Jump 91
- @Label 94
- Note "Ring…"
- Jump 91
-
-
- ! CONNECT xxxx/XXXX was detected
- @Label 95
- Jsr 98
- MatchClr
- MatchStr 1 96 "^$\r\n"
- MatchRead 10
- @Label 96
- SetVar A "^$"
- SetVar C "DATA"
- return
-
- ! CONNECT xxx was detected
- @Label 97
- Jsr 98
- SetVar C "DATA"
- return
-
- @Label 98
- ifStr B 99 ""
- return
- @Label 99
- SetVar B "^$"
- return
-
- !
- ! Processing an AT command:
- ! OK -> proceed
- ! ERROR or TimeOut ->exit -6019
- ! It can be called AFTER the "Write" command, since LineShare buffers input
- !
- @Label 100
- MatchClr
- MatchStr 1 103 "\r\nOK\r\n"
- MatchStr 2 102 "\r\nERROR\r\n"
- @Label 101
- MatchRead 20
- @Label 102
- Exit -6019
- @Label 103
- return
-
- !
- ! Processing an AT command in the numeric mode
- ! OK -> proceed
- ! ERROR or TimeOut ->exit -6019
- ! It can be called AFTER the "Write" command, since LineShare buffers input
- !
- @Label 110
- MatchClr
- MatchStr 1 103 "0\r"
- MatchStr 2 102 "4\r"
- Jump 101
-